function HandlePageSumExpenseParticular(gui, operator, now, options) {
  this._gui = gui;
  this._operator = operator;
  this._now = now;
  this._options = options

  this._createElements();
};

HandlePageSumExpenseParticular.prototype._createElements = function() {
  var _self = this;
  tr = this._gui.detail.particulars.insertRow(-1);
  td = tr.insertCell(-1);
  td.style.textAlign = 'center';
  td.appendChild(DOMUtils.getLoadingImage());
  
  this._loadData();
};

HandlePageSumExpenseParticular.prototype._loadData = function() {
  this._results = null;
  this._retrieveResults(1);
};

HandlePageSumExpenseParticular.prototype._verifyData = function() {
  if (this._results) {
    this._updateElements();
  }
};

HandlePageSumExpenseParticular.prototype._retrieveResults = function(page) {
  var _self = this;
  var args = '&c=' + encodeURIComponent('(d.category=\'' + this._options.name + '\') AND ' + ((this._options.user) ? '(d.userAccount LIKE \'%' + this._options.user + '%\')' : '1 = 1')) + '&p=' + page + '&from=' + JSON.stringify(this._options.from) + '&to=' + JSON.stringify(this._options.to) + '&u=' + encodeURIComponent(JSON.stringify(this._operator));
  new RequestUtils()._custom('iesumexpenseparticular', args, function(result, params) { _self._results = result;
                                                                                        _self._verifyData.call(_self);
                                                                                  }, null);
};

HandlePageSumExpenseParticular.prototype._updateElements = function() {
  var _self = this;
  DOMUtils.removeChildElements(this._gui.title);
  DlmanageUtils.clear(this._gui.detail);
  DlmanageUtils.clear(this._gui.summarize);
  
  this._gui.title.appendChild(document.createTextNode('Category: ' + (this._options.name).toUpperCase()));
  
  /*-----summarize-----*/
  this._gui.summarize.expense.appendChild(document.createTextNode('$' + (this._results.top.expense).toFixed(2)));
  this._gui.summarize.cash.appendChild(document.createTextNode('$' + (this._results.top.cash).toFixed(2)));
  this._gui.summarize.nonCash.appendChild(document.createTextNode('$' + (this._results.top.noncash).toFixed(2)));
  
  
  if (this._results.main.length == 0) {
    tr = this._gui.detail.particulars.insertRow(-1);
    td = tr.insertCell(-1);
    td.style.textAlign = 'center';
    td.style.width = '1024px';
    td.appendChild(document.createTextNode('N/A'));
    this._gui.detail.Graph.style.height = '0px';
  } else {
    /*-particulars--*/
    for (var k = 0,kl = this._results.main.length; k < kl; k++) {
      var r =  this._results.main[k];
      if (k % 2 == 0) {
        tr = this._gui.detail.particulars.insertRow(-1);
      }
      if (r.value == 0) {
        continue;
      }
      td = tr.insertCell(-1);
      td.style.width = '200px';
      td.style.height = '30px';
      td.align = 'left';
      td.style.paddingLeft = '15px';
      var a = document.createElement('a');
      a.href = '#';
      a.appendChild(document.createTextNode(r.name.toUpperCase()));
      a._name = r.name;
      a.onclick = function() { if (_self._operator.type == Constant.USER_TYPE_ADMINISTER) {
                                 var w = window.open('?p=pageadmin&t=pagesumexpensedetail&opts=' + JSON.stringify({ cat: _self._options.name, name: this._name, from: _self._options.from, to: _self._options.to, user: _self._options.user }), 'Expense', 'width=1050,height=768,scrollbars=1,location=0', true);
                                 w.focus();
                               } else if (_self._operator.type == Constant.USER_TYPE_STAFF) {
                                 var w = window.open('?p=pagestaff&t=pagesumexpensedetail&opts=' + JSON.stringify({ cat: _self._options.name, name: this._name, from: _self._options.from, to: _self._options.to, user: _self._options.user }), 'Expense', 'width=1050,height=768,scrollbars=1,location=0', true);
                                 w.focus();
                               }
                             };
      td.appendChild(a);
      td = tr.insertCell(-1);
      td.style.width = '300px';
      td.align = 'left';
      td.appendChild(document.createTextNode('$' + parseFloat(r.value).toFixed(2) + ' (' + ((r.value / this._results.top.expense) * 100).toFixed(2) + '% of total revenue)'));
    }
    this._gui.detail.Graph.style.height = '900px';
    ChartUtils.expense(this._gui.detail.Graph, this._results.main);
  }
};
